package net.rlair.sbdemo.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 切面2.
 *
 * @author zhouliangjun
 * @version 1.0.0.0
 */
@Component
@Aspect
@Order(2)
public class ZhouLiangJunAspect2 {


	@Pointcut("execution(* net.rlair.sbdemo.controller.UserController.list(..))")
	public void pointCut() {
	}

	/**
	 * 返回通知：目标方法正常执行完毕时执行以下代码
	 * @param jp 切点
	 * @param result 返回结果
	 */
	@AfterReturning(value = "pointCut()", returning="result")
	public void afterReturning(final JoinPoint jp, final Object result) {
		System.out.println("Aspect afterReturning ......");
	}

	/**
	 * 环绕通知：目标方法执行前后分别执行一些代码，发生异常的时候执行另外一些代码
	 */
	@Around("pointCut()")
	public Object around(final ProceedingJoinPoint invocation) throws Throwable {
		System.out.println("Around-------------start");
		Object result = invocation.proceed();
		System.out.println("Around-------------end");
		return result;
	}
}
